/*
 * @Author: your name
 * @Date: 2020-06-15 09:45:32
 * @LastEditTime: 2020-06-15 12:12:11
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \codeSnippet\server\app\controller\utils.js
 */
'use strict'
const svgCaptcha = require('svg-captcha')
const Controller = require('egg').Controller

class UtilsController extends Controller {
  async index() {
    const captcha = svgCaptcha.create({
      size: 4,
      fontSize: 50,
      width: 100,
      height: 40,
      noise: 3,
    })
    const { ctx } = this
    ctx.session.captcha = captcha.text
    console.log('===', ctx.session, 'tag')
    ctx.response.type = 'image/svg+xml'
    ctx.body = captcha.data
  }
}

module.exports = UtilsController
